package com.szrt.javaweb;

import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;


/**
 * 往请求里面 增 删  修 的时候 程序就会自动做点事情
 * @author Administrator
 *
 */
public class AttributeListenerDemo 
		implements 
		/*ServletContextAttributeListener,HttpSessionAttributeListener,*/
		ServletRequestAttributeListener {

	@Override
	public void attributeAdded(ServletRequestAttributeEvent srae) {
		
		
		System.out.println("add====================================================");
		String key   = srae.getName();
		Object value = srae.getValue();
		System.out.println("key="+key + ",value="+value);
		//只要往request里面放了一个属性：就会调用...
		System.out.println("调用了AttributeListenerDemo的attributeAdded的方法... 增加属性");
		System.out.println("add====================================================");
		
	}

	@Override
	public void attributeRemoved(ServletRequestAttributeEvent srae) {
		System.out.println("remove====================================================");
		String key   = srae.getName();
		Object value =  srae.getValue();
		System.out.println("key="+key + ",value="+value);
		System.out.println("调用了AttributeListenerDemo的attributeRemoved的方法...删除属性");
	}

	@Override
	public void attributeReplaced(ServletRequestAttributeEvent srae) {
		System.out.println("update====================================================");
		String key   = srae.getName();
		Object value =  srae.getValue();
		System.out.println("key="+key + ",value="+value);
		System.out.println("调用了AttributeListenerDemo的attributeReplaced的方法...修改属性");
		System.out.println("update====================================================");
		
	}

}
